@extends('admin.home.main')

@section('body')
<section id="main-content">

<section class="wrapper">
<h3><a href="/admin/teaching/talist">教具包管理</a>->教具包详情</h3>
<hr>
<div class="row mt">
  <div class="col-md-12">
    <a href="/admin/teaching/aidadd/{{$id}}" style="float:left; margin-left:10px;" class="btn btn-success">添加教具</a>
  </div>
</div>


<!-- row -->
<div class="row mt">
  <div class="col-md-12">
    <div class="content-panel">
      <table class="table table-striped table-advance table-hover">
        <thead>
          <tr>
            <th>#</th>
            <th>教具名称</th>
            <th>教具图片</th>
            <th>价格/货号</th>
            <th>标签</th>
            <th>库存</th>
            <th>销售量</th>
            <th>添加时间</th>
            <th>操作</th>
          </tr>
        </thead>
        <tbody>
          @foreach($aidList as $atm=>$ast)
            <tr>
              <td>{{$ast->id}}</td>
              <td>{{$ast->name}}</td>
              <td><img src="{{$ast->picture}}" style="width:100px;"></td>
              <td>价格:￥{{$ast->price}}<br>货号:{{$ast->item_num}}</td>
              <td>
                  <input type="checkbox" value="1" @if($ast->status == 1) checked="checked" @endif>上架<br>
                  <input type="checkbox" value="0" @if($ast->status == 0) checked="checked" @endif>新品<br>
                  <input type="checkbox" value="2" @if($ast->status == 2) checked="checked" @endif>推荐
              </td>
              <td>{{$ast->stock}}{{$ast->unit}}</td>
              <td>{{$ast->sale_num}}</td>
              <td>{{$ast->add_date}}</td>
              <td>
                <a href="/admin/teaching/aidedit/{{$ast->id}}" class="btn btn-primary btn-xs">编辑</a>
                <button type="button" colid="{{$ast->id}}" class="btn btn-danger btn-xs col_del">删除</button>
              </td>
            </tr>
          @endforeach
        </tbody>
      </table>

    </div>
    <!-- /content-panel -->
  </div>
  <!-- /col-md-12 -->
</div>
<!-- /row -->
</section>
</section>
<script type="text/javascript">
  $('.col_del').click(function(){
    var _colId = $(this).attr('colid');
    var a = confirm('请确认是否要删除该教具包');
    var t = $(this).parent().parent();

    if(a == true){
      $.ajax({
        'type':'get',
        'url':'/admin/teaching/aiddel/'+_colId,
        'dataType':'json',
        success:function(msg){
          if(msg.code == 200){
            alert('删除成功');
          }else{
            alert('删除失败');
          }
          location.reload();
        }
      })
    }
  })
</script>
@endsection